<?php

namespace Pader\DcatAdmin\ChinaDistpicker;

use Dcat\Admin\Admin;
use Dcat\Admin\Form;
use Dcat\Admin\Grid\Filter;
use Dcat\Admin\Extend\ServiceProvider;

class ChinaDistpickerServiceProvider extends ServiceProvider
{

    protected $js = [
        'dist/distpicker.min.js',
    ];


    public function init()
    {
        parent::init();

        $path = $this->getViewPath();
        $this->loadViewsFrom($path, 'pader-china-distpicker');

        if ($this->app->runningInConsole()) {
            $path = $this->getAssetPath();
            $this->publishes(
                [$path => public_path('vendors/dcat-admin-extensions/pader/china-distpicker')],
                'chg-china-distpicker'
            );
        }

        Admin::booting(function () {
            Form::extend('distpicker', Distpicker::class);
            Filter::extend('distpicker', DistpickerFilter::class);
        });
    }

}